//文章
import { BLOG, ADMIN } from './api';
import { request, METHOD } from '@/utils/request';
//创建文章
export async function addArticle(title, classify, content) {
  return request(BLOG + '/create', METHOD.POST, {
    title,
    classify,
    content,
  });
}
//修改文章
export async function editBLogApi(params) {
  return request(BLOG + '/updataBlog', METHOD.PUT, params);
}
//删除文章
export async function delBlogApi(params) {
  return request(ADMIN + '/deleteBlog/', METHOD.DELETE, params.blogId);
}
//获取该用户的文章
export async function getArticle(params) {
  return request(BLOG + '/get', METHOD.GET, params);
}
//获取所有文章
export async function blogListApi(params) {
  return request(BLOG + '/getAllBlog', METHOD.GET, params);
}
//搜索文章
export async function searchByIdApi(params) {
  return request(BLOG + '/search', METHOD.GET, params);
}
//根据分类id获取文章
export async function searchByKeyWordsApi(params) {
  return request(BLOG + '/searchByInput', METHOD.GET, params);
}
//根据文章id获取文章
export async function blogDetailApi(params) {
  return request(ADMIN + '/getBlogById', METHOD.GET, params);
}
//-------admin--------
//admin获取所有文章
export async function adminGetAllBlogApi(params) {
  return request(ADMIN + '/getAllBlog', METHOD.GET, params);
}
export default {
  addArticle,
  delBlogApi,
  editBLogApi,
  getArticle,
  blogListApi,
  searchByIdApi,
  searchByKeyWordsApi,
  blogDetailApi,
  adminGetAllBlogApi,
};
